package team.you.change.controller;

import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import team.you.change.util.Result;
import team.you.change.service.UserService;
import team.you.change.util.SendEmail;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/getAllUsers")
    @ResponseBody
    private Result getAllUsers(Integer page, Integer limit)
    {
        return userService.getAllUsers(page,limit);
    }
    @RequestMapping("/del")
    @ResponseBody
    private Result del(String id)
    {
        return userService.del(id);
    }
    @RequestMapping("/delete")
    @ResponseBody
    private Result delete(String[] ids)
    {
        return userService.delete(ids);
    }
    @RequestMapping("/update")
    @ResponseBody
    private Result update(String id,String value,String field)
    {
        return userService.update(id,value,field);
    }
    @RequestMapping("/selectByLike")
    @ResponseBody
    private Result selectByLike(String value,Integer type,Integer page,Integer limit)
    {
        return userService.selectByLike(value,type,page,limit);
    }
    @RequestMapping("/getTutorOption")
    @ResponseBody
    private Result getTutorOption()
    {
        return userService.getTutorOption();
    }
    @RequestMapping("/upImg")
    @ResponseBody
    private Result upImg(MultipartFile file, HttpServletRequest request){
        return userService.upImg(file, request);
    }
    @RequestMapping("/editInfo")
    @ResponseBody
    private Result editInfo(String id, String username, String realName, String idNumber, String head, HttpServletRequest request){
        return userService.editInfo(id, username, realName, idNumber, head, request);
    }
    @RequestMapping("/emailCode")
    @ResponseBody
    private Result test(@RequestBody List<String> email, HttpServletRequest request){ //加@RequestBody接收list
        return userService.emailCode(email, request);
    }
    @RequestMapping("/edit")
    @ResponseBody
    private Result edit(String id,String value, Integer type, HttpServletRequest request){
        return userService.edit(id, value, type, request);
    }
}
